#ifndef MONITORTHREAD_H
#define MONITORTHREAD_H

#include <windows.h>

class MonitorThread 
{
public:

	static DWORD WINAPI ThreadFunc(LPVOID pv)
	{
		try
		{
			(reinterpret_cast<MonitorThread *>(pv))->run();
		}
		catch(...)
		{
		}
		return 0;
	}
  typedef DWORD ThreadId;
    
	static void sleep(long milliseconds=1000)
	{
		::Sleep(milliseconds);
	}
	ThreadId start()
	{
		ThreadId id;
		::CreateThread(NULL, 0, ThreadFunc, this, 0, &id);
		return id;
	}
  virtual void run() = 0;
};


#endif
